package com.sql.common;

import com.sql.common.intc.SqlTypeConvert;

import java.sql.PreparedStatement;
import java.util.List;
import java.util.Map;

/**
 * Created by dell on 2017/11/24.
 */
public interface Dao {

    List<?> get(Class<?> clazz) throws Exception;

    List<?> get(Class<?> clazz, String where, Object... params) throws Exception;

    <T>T getOne(Class<?> clazz, String where, Object... params) throws Exception;

    <T>T getById(Class<?> clazz, Object id) throws Exception;

    /**
     * 获取数据通过自定义sql。sql的列必须通过as别名指定，并且指定为与属性名相同。
     * @param clazz
     * @param sql
     * @param params
     * @return
     * @throws Exception
     */
    List<?> getBySql(Class<?> clazz, String sql, Map<Integer, SqlTypeConvert> mapTypeConvert, Object... params) throws Exception;

    int insert(Object obj) throws Exception;

    int update(Object obj) throws Exception;

    int updateBySql(String sql, Object... params) throws Exception;

    int delete(Class<?> clazz, Object id) throws Exception;

    int delete(Class<?> clazz, String where, Object... params) throws Exception;

    PreparedStatement getPreparedStatement(String sql) throws Exception;

}
